package com.retail.proxy.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.proxy.entity.request.ProxyMechanismGroomRequest;
import com.retail.proxy.entity.vo.ProxyMechanismGroomVo;
import com.retail.proxy.service.ProxyMechanismGroomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 推荐奖励 API
* @author Administrator
*/
@Api(tags = "推荐奖励 API")
@RestController
@RequestMapping("/proxyMechanismGroom")
public class ProxyMechanismGroomController extends AbstractCommonController<ProxyMechanismGroomService, ProxyMechanismGroomRequest, ProxyMechanismGroomVo> {

    @Autowired
    private ProxyMechanismGroomService proxyMechanismGroomService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(proxyMechanismGroomService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存推荐奖励")
    public Result<Integer> save(@RequestBody ProxyMechanismGroomRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(proxyMechanismGroomService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新推荐奖励")
    public Result<Integer> update(@RequestBody ProxyMechanismGroomRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(proxyMechanismGroomService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("推荐奖励-查询")
    public Result<List<ProxyMechanismGroomVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(proxyMechanismGroomService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("推荐奖励-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(proxyMechanismGroomService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("推荐奖励-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<ProxyMechanismGroomRequest> req) {
        return super.page(proxyMechanismGroomService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除推荐奖励")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(proxyMechanismGroomService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除推荐奖励")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(proxyMechanismGroomService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
